package com.ext.aic.handler;

import com.ext.aic.beans.OCRProcessMeta;
import com.ext.aic.events.OnRecognizeListener;
import com.ext.aic.excutor.ProcessRunnable;
import com.eyinfo.android_pure_utils.utils.TaskUtils;

import java.util.List;
import java.util.Objects;

import lombok.Setter;

public class OCRPoolHandler {
    @Setter
    private OnRecognizeListener recognitionListener;

    public void process(OCRProcessMeta meta, int position) {
        TaskUtils.getInstance().execute(new ProcessRunnable(meta, position, recognitionListener));
    }

    public void concurrentlyProcess(List<OCRProcessMeta> metas) {
        if (Objects.isNull(metas)) {
            if (recognitionListener != null) {
                recognitionListener.onRecognizeCall("", -1, "", "");
            }
            return;
        }
        for (int i = 0; i < metas.size(); i++) {
            process(metas.get(i), i);
        }
    }
}
